{include file="../../../application/admin/view/public/head" /}

<div class="page-container">
    <form class="layui-form layui-form-pane" action="">
        <div class="layui-tab" lay-filter="tb1">
            <ul class="layui-tab-title">
                <li class="layui-this" lay-id="configemail_1">邮件模板配置</li>
                {volist name="$extends['ext_list']" id="vo"}
                <li data-key="{$key}" lay-id="configemail_{$i+1}">{$vo}</li>
                {/volist}
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">

                    <blockquote class="layui-elem-quote layui-quote-nm">
                        提示信息：<br>
                        修改后请先点击保存然后再测试发送。内容支持{literal}{$maccms.***}标签，  {$user.***}标签， {$code}验证码， {$time}有效时间{/literal}。
                    </blockquote>

                    <div class="layui-form-item">
                        <label class="layui-form-label">发送方式：</label>
                        <div class="layui-input-inline">
                            <select class="w150" id="ac" name="email[type]" lay-filter="ac">
                                <option value="" >请选择...</option>
                                {volist name="$extends['ext_list']" id="vo"}
                                <option value="{$key}" {if condition="$config['email']['type'] eq $key"}selected {/if}>{$vo}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">有效期限：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="email[time]" placeholder="" value="{$config['email']['time']}" class="layui-input w200"  >
                        </div>
                        <div class="layui-form-mid layui-word-aux">邮件验证码多少分钟后失效</div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">发件昵称：</label>
                        <div class="layui-input-inline">
                            <input type="text" id="nick" name="email[nick]" placeholder="" value="{$config['email']['nick']}" class="layui-input w200"  >
                        </div>
                        <div class="layui-form-mid layui-word-aux">发件人昵称</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">测试地址：</label>
                        <div class="layui-input-inline">
                            <input type="text" id="test" name="email[test]" placeholder="" value="{$config['email']['test']}" class="layui-input w200"  >
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" onclick="test_email()">发送测试邮件</button>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">测试标题：</label>
                        <div class="layui-input-block">
                            <input type="text" name="email[tpl][test_title]" placeholder="" value="{$config['email']['tpl']['test_title']}" class="layui-input"  >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">测试正文：</label>
                        <div class="layui-input-block">
                            <textarea name="email[tpl][test_body]" class="layui-textarea">{$config['email']['tpl']['test_body']}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">用户注册标题：</label>
                        <div class="layui-input-block">
                            <input type="text" name="email[tpl][user_reg_title]" placeholder="" value="{$config['email']['tpl']['user_reg_title']}" class="layui-input"  >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户注册正文：</label>
                        <div class="layui-input-block">
                            <textarea name="email[tpl][user_reg_body]" class="layui-textarea">{$config['email']['tpl']['user_reg_body']}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">用户绑定标题：</label>
                        <div class="layui-input-block">
                            <input type="text" name="email[tpl][user_bind_title]" placeholder="" value="{$config['email']['tpl']['user_bind_title']}" class="layui-input"  >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户绑定正文：</label>
                        <div class="layui-input-block">
                            <textarea name="email[tpl][user_bind_body]" class="layui-textarea">{$config['email']['tpl']['user_bind_body']}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">用户找回标题：</label>
                        <div class="layui-input-block">
                            <input type="text" name="email[tpl][user_findpass_title]" placeholder="" value="{$config['email']['tpl']['user_findpass_title']}" class="layui-input"  >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户找回正文：</label>
                        <div class="layui-input-block">
                            <textarea name="email[tpl][user_findpass_body]" class="layui-textarea">{$config['email']['tpl']['user_findpass_body']}</textarea>
                        </div>
                    </div>
                </div>
                {$extends['ext_html']}
            </div>

        </div>
        <div class="layui-form-item center">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="formSubmit">保 存</button>
                <button class="layui-btn layui-btn-warm" type="reset">还 原</button>
            </div>
        </div>
    </form>
</div>

{include file="../../../application/admin/view/public/foot" /}
<script type="text/javascript" src="__STATIC__/js/jquery.cookie.js"></script>
<script type="text/javascript">
    layui.use(['element', 'form', 'layer'], function() {
        var element = layui.element
            ,form = layui.form
            , layer = layui.layer;


        element.on('tab(tb1)', function(){
            $.cookie('configemail_tab', this.getAttribute('lay-id'));
        });

        if( $.cookie('configemail_tab') !=null ) {
            element.tabChange('tb1', $.cookie('configemail_tab'));
        }

    });
    function test_email() {
        var host = $("#host").val();
        var username = $("#username").val();
        var password = $("#password").val();
        var test = $("#test").val();
        var nick = $("#nick").val();
        var port = $('#port').val();

        layer.msg('数据提交中...',{time:500000});
        $.ajax({
            url: "{:url('system/test_email')}",
            type: "post",
            dataType: "json",
            data: {host:host,username:username,password:password,port:port,nick:nick,test:test},
            beforeSend: function () {
            },
            error:function(r){
                layer.msg('发生错误，请检查是否开启相应扩展库',{time:1800});
            },
            success: function (r) {
                layer.msg(r.msg,{time:1800});
            },
            complete: function () {
            }
        });
    }
</script>

</body>
</html>